package com.zui.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TimeConvert {

	/**
	 * 短日期转字符
	 * @param date
	 * @return
	 */
	public static String getShortDateToString(Date date){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		return sdf.format(date);
	}
	/**
	 * 短字符转日期
	 * @param str
	 * @return
	 */
	public static Date getShortStringToDate(String str){
		SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd");
		Date date = null;
		try {
			date = sdf.parse(str);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}
	/**
	 * 日期加1
	 * @param date
	 * @return
	 */
	public static Date getAddDate(Date date){
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.set(Calendar.DATE, cal.get(Calendar.DATE)+1);
		return cal.getTime();
	}
	
	public static void main(String[] args) {
		String target = "2323(33)sdd(222)";
		int leftBrackets = target.lastIndexOf("(");
		int rightBrackets = target.lastIndexOf(")");
		
		System.err.println(target.substring(leftBrackets+1, rightBrackets));
	}
}
